package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "订单商品", model = "订单商品")
@Entity
@Table(name = "bs_order_item")
@Comment("订单商品表")
public class OrderItem extends AbstractEntity {

    @Comment("订单ID")
    @FormField(title = "订单ID", sortNum = "1", grid = true, required = true)
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    @Comment("订单编号")
    @FormField(title = "订单编号", sortNum = "2", grid = true, required = true)
    @Column(name = "order_no", nullable = false, length = 64)
    private String orderNo;

    @Comment("商品ID")
    @FormField(title = "商品ID", sortNum = "3", grid = true, required = true)
    @Column(name = "product_id", nullable = false)
    private Long productId;

    @Comment("商品名称")
    @FormField(title = "商品名称", sortNum = "4", grid = true, required = true)
    @Column(name = "product_name", nullable = false, length = 200)
    private String productName;

    @Comment("商品编号")
    @FormField(title = "商品编号", sortNum = "5", grid = true, required = true)
    @Column(name = "product_sn", nullable = false, length = 64)
    private String productSn;

    @Comment("商品分类ID")
    @FormField(title = "商品分类ID", sortNum = "6", grid = true, required = true)
    @Column(name = "product_category_id", nullable = false)
    private Long productCategoryId;

    @Comment("商品品牌ID")
    @FormField(title = "商品品牌ID", sortNum = "7", grid = true)
    @Column(name = "product_brand_id")
    private Long productBrandId;

    @Comment("商品SKU ID")
    @FormField(title = "商品SKU ID", sortNum = "8", grid = true, required = true)
    @Column(name = "product_sku_id", nullable = false)
    private Long productSkuId;

    @Comment("商品SKU编号")
    @FormField(title = "商品SKU编号", sortNum = "9", grid = true, required = true)
    @Column(name = "product_sku_sn", nullable = false, length = 64)
    private String productSkuSn;

    @Comment("商品SKU名称")
    @FormField(title = "商品SKU名称", sortNum = "10", grid = true, required = true)
    @Column(name = "product_sku_name", nullable = false, length = 200)
    private String productSkuName;

    @Comment("商品SKU规格")
    @FormField(title = "商品SKU规格", sortNum = "11", grid = true)
    @Column(name = "product_sku_spec", length = 500)
    private String productSkuSpec;

    @Comment("商品图片")
    @FormField(title = "商品图片", sortNum = "12", type = InputType.image)
    @Column(name = "product_image", length = 500)
    private String productImage;

    @Comment("购买数量")
    @FormField(title = "购买数量", sortNum = "13", grid = true, type = InputType.el_input_number)
    @Column(name = "quantity", nullable = false)
    private Integer quantity = 1;

    @Comment("单价")
    @FormField(title = "单价", sortNum = "14", grid = true, type = InputType.el_input_number)
    @Column(name = "unit_price", nullable = false, precision = 10, scale = 2)
    private BigDecimal unitPrice = BigDecimal.ZERO;

    @Comment("总价")
    @FormField(title = "总价", sortNum = "15", grid = true, type = InputType.el_input_number)
    @Column(name = "total_price", nullable = false, precision = 10, scale = 2)
    private BigDecimal totalPrice = BigDecimal.ZERO;

    @Comment("优惠金额")
    @FormField(title = "优惠金额", sortNum = "16", grid = true, type = InputType.el_input_number)
    @Column(name = "discount_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal discountAmount = BigDecimal.ZERO;

    @Comment("实付金额")
    @FormField(title = "实付金额", sortNum = "17", grid = true, type = InputType.el_input_number)
    @Column(name = "pay_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal payAmount = BigDecimal.ZERO;

    @Comment("退款状态")
    @FormField(title = "退款状态", sortNum = "18", grid = true, type = InputType.select)
    @Column(name = "refund_status", nullable = false)
    private Integer refundStatus = 0;

    @Comment("退款金额")
    @FormField(title = "退款金额", sortNum = "19", grid = true, type = InputType.el_input_number)
    @Column(name = "refund_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal refundAmount = BigDecimal.ZERO;

    @Comment("退款时间")
    @FormField(title = "退款时间", sortNum = "20", type = InputType.date, grid = true)
    @Column(name = "refund_time")
    private LocalDateTime refundTime;

    @Comment("退款原因")
    @FormField(title = "退款原因", sortNum = "21", type = InputType.textarea)
    @Column(name = "refund_reason", length = 200)
    private String refundReason;
} 